/**
  * AntRanking Copyright (c) 2008-2012 INRIA, University of Lille 1
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * Contact: 
  * 	benjamin.bertein@gmail.com,
  * 	nacim.hamdad@gmail.com
  * 	nicolas.haderer@inria.fr
  *
  * Author: Nacim Hamdad,Benjamin Bertein, Haderer Nicolas
  */
package com.google.antranking.adapter;


import com.google.antranking.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ConfigurationListAdapter extends ArrayAdapter<Object>{

	private LayoutInflater inflator;
	
	private String[] labels;
	
	private String[] descriptions;
	
	private OnTouchListener[] listenners;
	
	public ConfigurationListAdapter(Context context, String[] names, String[] descriptions,
			OnTouchListener[] listenners){
		super(context,R.layout.row_list,names);
		
		inflator = (LayoutInflater) context
		.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		this.labels = names;
		this.descriptions = descriptions;
		this.listenners = listenners;
	}

	

	public View getView(int position, View convertView, ViewGroup parent) {
		
		View rowView = convertView;
		if (rowView == null) {
			
				rowView = inflator.inflate(R.layout.row_list,null);
				
				if (listenners[position] != null)
					rowView.
						setOnTouchListener(listenners[position]);
				
				TextView tvl =(TextView) rowView.findViewById(R.id.text_configuration_label);
				tvl.setText(this.labels[position]);
				
				tvl =(TextView) rowView.findViewById(R.id.text_configuration_description);
				tvl.setText(this.descriptions[position]);
		}
		
		return rowView;
		
	}

}
